package com.yxp.webtest.lifecycle;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.SmartLifecycle;

/**
 * @author      : yang.xp
 * @date        : 2021/10/14 11:27
 * @description : 參考spring servlet 的启动 WebServerStartStopLifecycle。主动启动tomcat容器
 */
@Slf4j
public class MyServerLifecycle implements SmartLifecycle {

    private volatile boolean running;

    @Override
    public void start() {
        log.info(" MyServerLifecycle start ");
        this.running = true;
    }

    @Override
    public void stop() {
        log.info(" MyServerLifecycle stop ");
        this.running = false;
    }

    @Override
    public boolean isRunning() {
        return this.running;
    }
}
